package p366;/**
 * @Author：ming
 * @Date：2023/10/14 12:17 PM
 * @Filename：Lc2839
 */

import java.util.ArrayList;
import java.util.Collections;

/**
 * @author ming
 */
public class Lc2839 {
    public boolean canBeEqual(String s1, String s2) {
        ArrayList<Character> l1 = new ArrayList<>();
        ArrayList<Character> l2 = new ArrayList<>();

        for (int i = 0; i < s1.length(); i+=2) {
            l1.add(s1.charAt(i));
            l2.add(s2.charAt(i));
        }
        Collections.sort(l1);
        Collections.sort(l2);
        if(!l1.equals(l2)){
            return false;
        }

        l1.clear();
        l2.clear();
        for (int i = 1; i < s1.length(); i+=2) {
            l1.add(s1.charAt(i));
            l2.add(s2.charAt(i));
        }

        Collections.sort(l1);
        Collections.sort(l2);
        if(!l1.equals(l2)){
            return false;
        }

        return true;

    }
}
